/*
 * Copyright(C) 2017 Hangzhou Differsoft Co., Ltd. All rights reserved.
 */

package com.ruoyi.business.domain.jackyun;


import java.util.List;

/**
 * 请求吉客云开放平台服务。
 *
 * @author hup
 * @since 2018-08-29  14:46:43
 */
public class JackyunOpenClientService {
    /**
     * 请求开放平台服务。
     * @param method 开放接口方法名
     * @param bizData 请求业务数据
     * @param memberInfo 开放平台申请应用实体
     * @return OpenResponse返回对象
     */
    public JackyunResponse call(String method, BaseRequestBizData bizData, JackyunMemberInfo memberInfo) {
        //接口返回值
        JackyunResponse response = null;
        //返回值字符串
        String strResponse = null;
        try {
            //请求吉客云开放接口。
            strResponse = JackyunOpenHttpUtils.post(method, "v1.0", JsonUtils.toJson(bizData),memberInfo);
        } catch (Exception ex) {
            response = new JackyunResponse();
            response.onFail(ex.getMessage(), "CLIENT_EXCEPTION");
            return response;
        }
        return JsonUtils.deJson(strResponse, JackyunResponse.class);
    }

    /**
     * 请求开放平台服务。
     * @param method 开放接口方法名
     * @param bizDataList 请求业务数据 数组
     * @param memberInfo 开放平台申请应用实体
     * @return OpenResponse返回对象
     */
    public JackyunResponse callBatch(String method, List<BaseRequestBizData> bizDataList, JackyunMemberInfo memberInfo) {
        //接口返回值
        JackyunResponse response = null;
        //返回值字符串
        String strResponse = null;
        try {
            //请求吉客云开放接口。
            strResponse = JackyunOpenHttpUtils.post(method, "v1.0", JsonUtils.toJson(bizDataList),memberInfo);
        } catch (Exception ex) {
            response = new JackyunResponse();
            response.onFail(ex.getMessage(), "CLIENT_EXCEPTION");
            return response;
        }
        return JsonUtils.deJson(strResponse, JackyunResponse.class);
    }
}
